package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.entity.AddressBook;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface AddressBookMapper {
    /**
     * 查询地址簿
     * @param addressBook
     * @return
     */
    @Select("select * from address_book where user_id = #{userId}")
    List<AddressBook> list(AddressBook addressBook);

    /**
     * 设置默认地址
     * @param addressBook
     */
    void setDefaultAddress(AddressBook addressBook);

    /**
     * 设置非默认地址
     * @param addressBook
     */
    void setNotDefaultAddress(AddressBook addressBook);

    /**
     * 查询默认地址
     * @param addressBook
     * @return
     */
    AddressBook queryDefaultAddress(AddressBook addressBook);

    /**
     * 新增地址
     * @param addressBook
     */
    void insert(AddressBook addressBook);

    /**
     * 根据id删除地址
     * @param addressBook
     */
    @Delete("delete from address_book where id = #{id} and user_id = #{userId}")
    void deleteAddressById(AddressBook addressBook);

    /**
     * 根据id查询地址
     * @param id
     * @return
     */
    @Select("select * from address_book where id = #{id}")
    AddressBook getById(Long id);

    void updateAddress(AddressBook addressBook);
}
